# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=python_ics
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=4.3
pkgrel=2
pkgdesc="Python C Code module for interfacing to the icsneo40 dynamic library (mingw-w64)"
arch=('any')
url='https://github.com/intrepidcs/python_ics/'
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=('staticlibs' 'strip' '!debug')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/intrepidcs/python_ics/archive/v${pkgver}.tar.gz"
        mingw-build.patch)
sha512sums=('0309a1ab9748de83ed69819229cb946384931d7629439003e635b4fbac235d62e20eb3f5d4366912597adabc2aefc5b087cb96bc055a5c31b5d16f46681d2e0d'
            '3c8622868fc017ca8d7f4ceb7ab7bfd4e2bfb6cc9be437f0a923b02d525fa23e3349990b5dc055e04a47be79a01ecdcd6358b7169d6e4f23cbaa7e47425b3bd5')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/mingw-build.patch

  cd "${srcdir}"
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
}

build() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  #install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
